//
//  BLBlacklistView.swift
//  BLLiveTelecast
//
//  Created by BigL055 on 16/6/20.
//  Copyright © 2016年 bigL.liveTelecast.com. All rights reserved.
//

import UIKit

class BLBlacklistView: UIView {
    
    var animateDuration : NSTimeInterval = 2.0
    
    /// 用户头像
    @IBOutlet private weak var userImageView: UIImageView!
    /// 用户昵称
    @IBOutlet private weak var nickNameLabel: UILabel!
    
    @IBOutlet weak var levelImageView: UIImageView!
    
    // 背景蒙版View
    var coverView: UIView?
    
    
    /// 初始化
    class func viewNew() -> BLBlacklistView {
        let view = NSBundle.mainBundle().loadNibNamed(String(BLBlacklistView), owner: nil, options: nil).last as! BLBlacklistView
        return view
    }
    
    /// 信息设置
    func setBlacklistViewInfo(userImageUrlStr : String,
                              nickNameStr : String,
                              level : String) {
        if userImageUrlStr != "" {
            userImageView.sd_setImageWithURL(NSURL(string: userImageUrlStr))
        }
        if nickNameStr != "" {
            nickNameLabel.text = nickNameStr
        }
        if level != "" {
            levelImageView.image = UIImage(named: "Level_\(level)")
        }
        
    }
    
    func show() {
        
        // 背景蒙版View
        coverView = UIView(frame: CGRect(x: 0, y: 0, width: BL_SCREEN_WIDTH, height: BL_SCREEN_HEIGHT))
        coverView?.backgroundColor = UIColor.blackColor()
        coverView?.alpha = 0.3
        UIApplication.sharedApplication().keyWindow?.addSubview(coverView!)
        
        // 黑名单窗口
        let width = BL_SCREEN_WIDTH * 0.8
        self.bl_setSize(CGSize(width: width, height: width / BLVideoRtatio_16x9))
        self.bl_setOrigin(CGPoint(x: (BL_SCREEN_WIDTH - width) * 0.5, y: BL_SCREEN_HEIGHT))
        UIApplication.sharedApplication().keyWindow?.addSubview(self)
        
        UIView.animateWithDuration(0.5) {
            self.bl_setBottom(BL_SCREEN_HEIGHT * 0.5)
        }
    }
    
    /// 关闭窗口按钮
    @IBAction private func closeBtnClick(sender: UIButton) {
        
        // 移除黑名单窗口
        UIView.animateWithDuration(0.5, animations: { 
            self.bl_setTop(BL_SCREEN_HEIGHT)
            }) { (Bool) in
                self.coverView?.removeFromSuperview()
        }
        self.removeFromSuperview()
        
    }
    
    /// 屏蔽用户
    @IBAction private func blackUserBtnClick(sender: UIButton) {
        print("屏蔽用户")
        
        
        
    }
    
    /// 举报用户
    @IBAction private func reportBtnClick(sender: UIButton) {
        print("举报用户")
        
    }
    
}
